1. Tips: 省略屬性名稱

當物件的屬性與函式/變數名稱相同時,可以省略不寫 !!!

// 原本的寫法
const view = {
  displayCards: function displayCards() { ...  }
}
// 省略後的寫法
const view = {
  displayCards() { ...  }
}

2. 解構賦值 destructuring assignment

let [a, b, c] = [1, 2, 3]
只要等號兩邊的模式相同 (例如都是 [] 或都是 {}),左邊的變數就會被賦予右邊的對應值。


#省略屬性名稱 #解構賦值 destructuring assignment







Related Posts

讀書筆記-JavaScript技術手冊4: 物件基本語法

讀書筆記-JavaScript技術手冊4: 物件基本語法

筆記:What the heck is the event loop anyway | Philip Roberts | JSConf EU

筆記:What the heck is the event loop anyway | Philip Roberts | JSConf EU

Git 版本控制

Git 版本控制


Comments